import urllib.request
import ssl

# 小坑不知道为什么一直请求不成功， 百度了下加上这个之后就好了
ssl._create_default_https_context = ssl._create_unverified_context
# 下载html   有坑有https的网站不让下
url_html = 'https://www.mate98.cn/'
headers = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
}

request = urllib.request.Request(url=url_html, headers=headers)

response = urllib.request.urlopen(request)
content = response.read().decode('utf-8')
print(content)

urllib.request.urlretrieve(url=url_html, filename="mate98.html")

# 图片
# url_img = 'http://img0.baidu.com/it/u=1512144402,1033027284&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889'
#
# urllib.request.urlretrieve(url_img, 'lisa.png')

# 视频
# url_vide = 'http://v26-web.douyinvod.com/fe9f8b3cc4d507e609e86a3638879420/64872ce2/video/tos/cn/tos-cn-ve-15c001-alinc2/owTcW2aDwWQUeDFIAtgI7ED8ubbXheBEBnECAf/?a=6383&ch=5&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=232&bt=232&cs=2&ds=3&ft=bvTKJbQQqUisf_0ZPo0OW_EklpPiX_1lDMVJEr2qYRCPD-I&mime_type=video_mp4&qs=15&rc=Zmg3NWRmaTU2ZWVlNDUzZEBpM2R2bjc6ZjhqazMzNGkzM0AvLy1hXmEvXjIxNl9gYTVfYSMuczNxcjRnYXFgLS1kLS9zcw%3D%3D&l=202306122133104D9BCBA61E066B145579&btag=e00020000'
#
# urllib.request.urlretrieve(url_vide, 'douyin.mp4')
